import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/7 14:55
 * @description 暴力
 */
public class Solution {
    public static void main(String[] args) {

    }

    public int nextBeautifulNumber(int n) {
        while (true) {
            n++;
            if (check(n)) {
                return n;
            }
        }
    }
    public boolean check(int n) {
        int[] cnt = new int[10];
        while (n != 0) {
            cnt[n % 10]++;
            n /= 10;
        }
        for (int i = 0; i < 10; i++) {
            if (cnt[i] != 0 && cnt[i] != i) {
                return false;
            }
        }
        return true;
    }
}
